#!/usr/bin/env python
#coding=utf-8

#切分数据:respond与not_respond
#读源数据
from config import DISCRETED_FILE,FILEPATH_R,FILEPATH_N

if __name__ == "__main__":
    file = open( DISCRETED_FILE,"r" )
    file_r = open( FILEPATH_R,"w" )#建立结果文件
    file_n = open( FILEPATH_N,"w" )
    
    lines = file.readlines()
    #写一行item名称
    file_r.write(lines[0])
    file_n.write(lines[0])
    
    for i in range(1,len(lines)):
        lines_temp = lines[i].rstrip()#除去最后一个回车符
        arr = lines_temp.split(',')
        r_n = arr[-2]
        if r_n == '0':
            file_n.write(lines[i])
        else:
            file_r.write(lines[i])
    print "Split finished:"+FILEPATH_R+"\t"+FILEPATH_N
    
